<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="../css/classify.css" />
    <link rel="stylesheet" href="../iconfont/iconfont.css" />
    <link rel="stylesheet" href="../css/bot.css" />
    <script src="../node_modules/axios/dist/axios.js"></script>
  </head>
  <body>
    <!-- 头部 -->
    <div id="app">
      <header>
        <div class="title">
          <h4>全部分类</h4>
        </div>
        <div class="search">
          <span class="iconfont icon-fangdajing"></span>
          <span>搜索商品</span>
        </div>
      </header>
      <!-- 主体 -->
      <div class="main">
        <div class="left">
          <ul>
            <li
              :class="{active:activeIndex===index}"
              @click="activeIndex = index"
              v-for="(item,index) in list"
              :key="index.id"
            >
              {{item.name}}
            </li>
          </ul>
        </div>
        <div class="right">
          <div v-for="(item,index) in list[activeIndex].children">
            <img :src="item.image.external_url" alt="" />
            <p>{{item.name}}</p>
          </div>
        </div>
        <!-- 底部 -->
        <div class="bottom">
          <a href="../index.html"
            ><div>
              <img src="../img/home.png" alt="" />
              <p>首页</p>
            </div></a
          >
          <a href="#"
            ><div>
              <img src="../img/cate-active.png" alt="" />
              <p style="color: #fa2209">分类</p>
            </div></a
          >
          <a href="./gwc.html"
            ><div>
              <img src="../img/1003.png" alt="" />
              <p>购物车</p>
            </div></a
          >
          <a href="./wode.html"
            ><div>
              <img src="../img/10007.png" alt="" />
              <p>我的</p>
            </div></a
          >
        </div>
      </div>
    </div>
    <!-- <script src="../js/classify.js"></script> -->
    <script src="../vue.js"></script>
    <script>
      const app = new Vue({
        el: '#app',
        data: {
          activeIndex: 0,
          list: []
        },
        created() {
          this.classify()
        },
        methods: {
          async classify() {
            const res = await axios.get(
              'http://cba.itlike.com/public/index.php?s=/api/category/list'
            )
            console.log(res.data.data.list)
            this.list = res.data.data.list
          }
        }
      })
    </script>
  </body>
</html>
